{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">会员卡列表</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
        <script type="text/html" id="barTool">

            <a class="layui-btn layui-btn-xs" data-open='{:url("activation")}?id={{ d.id }}' data-title="激活会员卡"
               data-full="true">激活会员卡</a>

            {{# if(d.status!=1){ }}
            <a href='{:url("del")}?ids={{ d.id }}'
               class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>

            {{# } }}

        </script>

    </div>
</div>
{/block}
{block name="script"}
<script>
layui.use('yznTable', function() {
    var table = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        add_url: "{:url('mcard_add')}?mcid={$mcid}",
        edit_url: "{:url('edit')}",
        delete_url: "{:url('del')}",
    };

    table.render({
        init: init,
        id: 'currentTable',
        elem: '#currentTable',
        url: '{:url("mcard_list")}?mcid={$mcid}',
        toolbar: ['refresh', [{
            text: '生成会员卡',
            url: init.add_url,
            method: 'open',
            icon: 'iconfont icon-add',
            class: 'layui-btn layui-btn-normal layui-btn-sm',
            // extend: 'data-full="true"',
        }]],
        cols: [
            [
                // { type: 'checkbox', fixed: 'left' },
                { field: 'id', align: "center", width: '8%', title: 'ID' , search: false},
                { field: 'no', align: "center", width: '15%', title: '卡号', search: false},
                { field: 'secret', align: "center", width: '15%', title: '秘钥', search: false},
                {
                    field: 'status',align: "center", width: '15%', title: '激活状态',
                    templet: function (d) {
                        if (d.status == 0) {
                            return '<span style="color: green">未激活</span>';
                        } else if (d.status == 1) {
                            return '<span style="color: orange">已激活</span>';
                        }else{
                            return '<span>未知</span>'
                        }
                    }, selectList: {0: '未激活', 1: '激活'}
                },
                {field: 'create_time', width: '15%',align: "center", title: '创建时间', search: false},
                {field: 'status_time', width: '15%',align: "center", title: '激活时间', search: false},
                {fixed: 'right', align: 'center',width: '20%', title: '操作', toolbar: '#barTool'}
            ]
        ],
        page: {}
    });
    yznTable.bindevent();
});
</script>
{/block}